﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntityMapperCreater.DataAccess
{
    public static class InitStaticData
    {
        /// <summary>
        /// DBConfig配置路径
        /// </summary>
        public static string dbPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\DBConfig.xml");
        public static string dbVersion { get; internal set; }
        public static IDatabaseService conn { get; private set; }
        public static bool IsConn { get; private set; }
        public static string mapperpath { get; internal set; } = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Mapper");

        /// <summary>
        /// 数据库端的检查和初始化参数
        /// </summary>
        public static void sysConfig(string databaseType)
        {
            if (conn != null) return;
            if (string.IsNullOrWhiteSpace(databaseType)) throw new ArgumentNullException("请选择一种数据库类型！");
            switch (databaseType)
            {
                case "sqlite":
                    conn = new SqliteDatabaseService();
                    IsConn = true;
                    break;
                case "mysql":
                    conn = new MysqlDatabaseService();
                    IsConn = true;
                    break;
                default:
                    IsConn = false;
                    break;
            }
        }
    }
}
